import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Vector;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;


public class CoCurricularGrades extends JPanel implements ActionListener {
	
	private SystemEssentials gui = new SystemEssentials(7);
	private JButton bComp, bAcads, bConduct, bCo, bRHGP, bAtt;
	private JLabel lViewClass;
	private JCheckBox cView[] = new JCheckBox[5];
	private JComboBox cbFilterBy, cbStatus;
	public String[] sFilterBy = {"---", "Status", "Position", "Area", "Sections Handled"};
	public String[] sStatus = {"---", "Active", "Grades"};
	
	private ImageIcon iComp = new ImageIcon("gui/buttons/bComp.png"),
					  iComp_ = new ImageIcon("gui/buttons/bComp_.png"),
					  iAcads = new ImageIcon("gui/buttons/bAcads.png"),
					  iAcads_ = new ImageIcon("gui/buttons/bAcads_.png"),
					  iConduct = new ImageIcon("gui/buttons/bConduct.png"),
					  iConduct_ = new ImageIcon("gui/buttons/bConduct_.png"),
					  iCo = new ImageIcon("gui/buttons/bCo.png"),
					  iCo_ = new ImageIcon("gui/buttons/bCo_.png"),
					  iViewClass = new ImageIcon("gui/labels/labelClass.png"),
					  iRHGP = new ImageIcon("gui/buttons/bRHGP.png"),
	  				  iRHGP_ = new ImageIcon("gui/buttons/bRHGP_.png"),
	  				  iAtt = new ImageIcon("gui/buttons/bAtt.png"),
	  				  iAtt_ = new ImageIcon("gui/buttons/bAtt_.png");
	
	public CoCurricularGrades(){
		setLayout(null);
		setBounds(0,0,700,600);	
		setOpaque(false);

		refreshTable();
		createGui();		
	}
	
	public void createGui(){
		for(int i=0; i<5; i++){
			cView[i] = new JCheckBox();
			cView[i].addActionListener(this);
			cView[i].setSelected(true);
			switch(i){
			case 0: cView[i].setText("Status"); break;
			case 1: cView[i].setText("First Name"); break;
			case 2: cView[i].setText("Last Name"); break;
			case 3: cView[i].setText("Participation"); break;
			case 4: cView[i].setText("Equivalent"); break;
			}
			cView[i].setBounds(25,440+(i*19),140,19);
			if(i==5)
				cView[5].setVisible(false);
			add(cView[i]);
		}
		
		cbFilterBy = new JComboBox(sFilterBy);
		cbFilterBy.setBounds(170,440,190,30);
		cbFilterBy.addActionListener(this);
		add(cbFilterBy);
		
		cbStatus = new JComboBox(sStatus);
		cbStatus.setBounds(170,480,190,30);
		add(cbStatus);
		
		bComp = new JButton(iComp);
		bComp.setBounds(580,105,102,18);
		bComp.setRolloverIcon(iComp_);
		bComp.setBorderPainted(false);
		bComp.setContentAreaFilled(false);
		bComp.setVisible(true);
		bComp.addActionListener(this);
		add(bComp);
		
		bAcads = new JButton(iAcads);
		bAcads.setBounds(485,105,90,18);
		bAcads.setRolloverIcon(iAcads_);
		bAcads.setBorderPainted(false);
		bAcads.setContentAreaFilled(false);
		bAcads.setVisible(true);
		bAcads.addActionListener(this);
		add(bAcads);
		
		bConduct = new JButton(iConduct);
		bConduct.setBounds(405,105,75,18);
		bConduct.setRolloverIcon(iConduct_);
		bConduct.setBorderPainted(false);
		bConduct.setContentAreaFilled(false);
		bConduct.setVisible(true);
		bConduct.addActionListener(this);
		add(bConduct);
		
		bCo = new JButton(iCo);
		bCo.setBounds(280,105,122,18);
		bCo.setRolloverIcon(iCo_);
		bCo.setBorderPainted(false);
		bCo.setContentAreaFilled(false);
		bCo.setVisible(true);
		bCo.addActionListener(this);
		add(bCo);
		
		bRHGP = new JButton(iRHGP);
		bRHGP.setBounds(220,105,54,18);
		bRHGP.setRolloverIcon(iRHGP_);
		bRHGP.setBorderPainted(false);
		bRHGP.setContentAreaFilled(false);
		bRHGP.setVisible(true);
		bRHGP.addActionListener(this);
		add(bRHGP);
		
		bAtt = new JButton(iAtt);
		bAtt.setBounds(120,105,98,18);
		bAtt.setRolloverIcon(iAtt_);
		bAtt.setBorderPainted(false);
		bAtt.setContentAreaFilled(false);
		bAtt.setVisible(true);
		bAtt.addActionListener(this);
		add(bAtt);
		
		add(gui);		
	}
		
	public void actionPerformed(ActionEvent a) {
		if(a.getSource() == bComp){
			MainPanel.goToPage(5);
		}
		if(a.getSource() == bAcads){
			MainPanel.goToPage(6);
		}
		if(a.getSource() == bCo){
			MainPanel.goToPage(11);
		}
		if(a.getSource() == bConduct){
			MainPanel.goToPage(8);
		}
		if(a.getSource() == bRHGP){
			MainPanel.goToPage(12);
		}
		if(a.getSource() == bAtt){
			MainPanel.goToPage(13);
		}
	}
		
	public void refreshTable(){
		gui.resetTableModel(7);
		// for input data from sql
		
		for(int i=0; i<1; i++){
			Vector<String> rowData = new Vector<String>();
			//sample
			rowData.add("9700106");
			rowData.add("Active");
			rowData.add("Rose Ann");
			rowData.add("Ebora");
			rowData.add("98");
			rowData.add("E");
			//sample
			gui.model.addRow(rowData);
		}

		for(int i=0; i<gui.model.getColumnCount(); i++){
			gui.table.getColumnModel().getColumn(i).setCellRenderer(gui.cellRenderer);
			gui.setColumnWidth(i,1);
		}
		
		for(int i=0; i<1; i++){
			Vector<String> rowData = new Vector<String>();
			//sample
			rowData.add("9700069");
			rowData.add("Active");
			rowData.add("Miguel");
			rowData.add("Arcilla");
			rowData.add("89");
			rowData.add("G");
			//sample
			gui.model.addRow(rowData);
		}

		for(int i=0; i<gui.model.getColumnCount(); i++){
			gui.table.getColumnModel().getColumn(i).setCellRenderer(gui.cellRenderer);
			gui.setColumnWidth(i,1);
		}
	}
		
	public void refreshGUI(){
		refreshTable();
		gui.refreshGUI();
	}
}
